home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / listcmos.arc / LISTCMOS.C next >
C/C++ Source or Header  |  1989-06-10  |  11KB  |  191 lines

  1. #include "stdio.h"
  2. #include "conio.h"
  3. #include "ctype.h"
  4.  
  5. char    cmos[64];
  6. int    i;
  7.  
  8. void    printdesc();
  9.  
  10. void main(argc,argv)
  11. int  argc;
  12. char *argv[];
  13. {
  14.     /* Read all the CMOS RAM memory (64 bytes) */
  15.     for (i=0; i<64; i++) {
  16.         outp(0x70, i);
  17.         cmos[i] = (char) inp(0x71);
  18.         }
  19.  
  20.     /* Display all the information */
  21.     printf("                 ┌────────────────────────────────────────────┐\n");
  22.     printf("                 │ AT CMOS Ram List - Ed Luebke (Version 1.1) │\n");
  23.     printf("┌──────┬─────┬───┴─────────────────────╥──────┬─────┬─────────┴───────────────┐\n");
  24.     printf("│ Byte │Value│ Description             ║ Byte │Value│ Description             │\n");
  25.     printf("├──────┼─────┼─────────────────────────╫──────┼─────┼─────────────────────────┤\n");
  26.     printf("│  00  │  %02X │ Seconds                 ║  14  │  %02X │ Equipment byte          │\n", cmos[0], cmos[0x14]);
  27.     printf("│  01  │  %02X │ Seconds (alarm)         ║  15  │  %02X │ Low base memory         │\n", cmos[1], cmos[0x15]);
  28.     printf("│  02  │  %02X │ Minutes                 ║  16  │  %02X │ High base memory        │\n", cmos[2], cmos[0x16]);
  29.     printf("│  03  │  %02X │ Minutes (alarm)         ║  17  │  %02X │ Low Expansion Memory    │\n", cmos[3], cmos[0x17]);
  30.     printf("│  04  │  %02X │ Hours                   ║  18  │  %02X │ High Expansion Memory   │\n", cmos[4], cmos[0x18]);
  31.     printf("│  05  │  %02X │ Hours   (alarm)         ║19-2d │     │ Reserved                │\n", cmos[5]);
  32.     printf("│  06  │  %02X │ Day of week             ║      │     │ %02X %02X %02X %02X %02X %02X %02X %02X │\n",
  33.                     cmos[6], cmos[0x19], cmos[0x1a], cmos[0x1b], cmos[0x1c], cmos[0x1d],
  34.                                 cmos[0x1e], cmos[0x1f], cmos[0x20]);
  35.     printf("│  07  │  %02X │ Date of month           ║      │     │ %02X %02X %02X %02X %02X %02X %02X %02X │\n",
  36.                    cmos[7], cmos[0x21], cmos[0x22], cmos[0x23], cmos[0x24], cmos[0x25],
  37.                                 cmos[0x26], cmos[0x27], cmos[0x28]);
  38.     printf("│  08  │  %02X │ Month                   ║      │     │ %02X %02X %02X %02X %02X          │\n",
  39.                    cmos[8], cmos[0x29], cmos[0x2a], cmos[0x2b], cmos[0x2c], cmos[0x2d]);
  40.     printf("│  09  │  %02X │ Year                    ║  2e  │  %02X │ CMOS checksum (high)    │\n", cmos[9], cmos[0x2e]);
  41.     printf("│  0a  │  %02X │ Status Reg A            ║  2f  │  %02X │ CMOS checksum (low)     │\n", cmos[0x0a], cmos[0x2f]);
  42.     printf("│  0b  │  %02X │ Status Reg B            ║  30  │  %02X │ Low expansion memory    │\n", cmos[0x0b], cmos[0x30]);
  43.     printf("│  0c  │  %02X │ Status Reg C            ║  31  │  %02X │ High expansion memory   │\n", cmos[0x0c], cmos[0x31]);
  44.     printf("│  0d  │  %02X │ Status Reg D            ║  32  │  %02X │ Date century            │\n", cmos[0x0d], cmos[0x32]);
  45.     printf("│  0e  │  %02X │ Diagnostic status       ║  33  │  %02X │ Information flags       │\n", cmos[0x0e], cmos[0x33]);
  46.     printf("│  0f  │  %02X │ Shutdown status         ║34-3f │     │ Reserved                │\n", cmos[0x0f]);
  47.     printf("│  10  │  %02X │ Diskette type (A & B)   ║      │     │ %02X %02X %02X %02X %02X %02X %02X %02X │\n",
  48.                    cmos[0x10], cmos[0x34], cmos[0x35], cmos[0x36], cmos[0x37], cmos[0x38],
  49.                                  cmos[0x39], cmos[0x3a], cmos[0x3b]);
  50.     printf("│  11  │  %02X │ Reserved                ║      │     │ %02X %02X %02X %02X             │\n",
  51.                    cmos[0x11], cmos[0x3c], cmos[0x3d], cmos[0x3e], cmos[0x3f]);
  52.     printf("│  12  │  %02X │ Fixed Disk type (C & D) ║      │     ├─────────────────────────┤\n", cmos[0x12]);
  53.     printf("│  13  │  %02X │ Reserved                ║      │     │ Use /d for descriptions │\n", cmos[0x13]);
  54.     printf("└──────┴─────┴─────────────────────────╨──────┴─────┴─────────────────────────┘");
  55.  
  56.     if (argc > 1) {
  57.         if (toupper(argv[1][1]) == 'D')
  58.             printdesc();
  59.         }
  60. }                       
  61.                                                                                                                       
  62. void    printdesc()
  63. {
  64.     printf("\n\n   CMOS RAM Description\n");
  65.     printf("  The setup program initializes registers A, B, C, and D when the\n");
  66.     printf("  time and date are set.  Also, Interrupt 1A is the BIOS' interface\n");
  67.     printf("  to read/set the time and date which also initializes the status bytes.\n");
  68.     printf("\n\n");
  69.     printf("STATUS REGISTER A (Hex A)\n");
  70.     printf("Bit 7      Update in Progress.  A 1 indicates the time update cycle is\n");
  71.     printf("         in progress.  A 0 indicates current date/time available\n");
  72.     printf("Bit 6-4  22-Stage Divider.  These three bits identify which time-base\n");
  73.     printf("         is being used.  Default is 010, 32.786kHz time base.\n");
  74.     printf("Bit 3-0  Rate Selection Bits.  These allow the selection of a divider\n");
  75.     printf("         output frequency.  Default is 0110, 1.024kHz square wave and\n");
  76.     printf("         a 976.562 microsecond periodic interrupt rate.\n");
  77.     printf("\n");
  78.     printf("STATUS REGISTER B (Hex B)\n");
  79.     printf("Bit 7    Set - A 0 updates the cycle normally by advancing the count at\n");
  80.     printf("         one-per-second.  A 1 aborts any update cycle in progress and\n");
  81.     printf("         the program can initialize the 14 time-bytes without any further\n");
  82.     printf("         updates occurring until a 0 is written to this bit.\n");
  83.     printf("Bit 6    Periodic Interrupt Enable.  Allows an interrupt to occur at a\n");
  84.     printf("         rate specified by the rate and divider bits in register A.  A\n");
  85.     printf("         1 enables an interrupt, a 0 disables it.  Default is 0.\n");
  86.     printf("Bit 5    Alarm Interrupt Enable.  A 1 enables the alarm interrupt, and\n");
  87.     printf("         a 0 disables it.  Default is 0.\n");
  88.     printf("Bit 4    Update-Ended Interrupt Enabled.  A 1 enables the update-ended\n");
  89.     printf("         interrupt, and a 0 disables it.  Default is 0.\n");
  90.     printf("Bit 3    Square Wave Enabled.  A 1 enables the square-wave frequency as\n");
  91.     printf("         set by the rate selection bits in register A, and a 0 disables\n");
  92.     printf("         the square wave.  Default is 0.\n");
  93.     printf("Bit 2    Date Mode.  Indicates whether the date/time is in binary or BCD\n");
  94.     printf("         format.  A 1 indicates binary, and a 0 BCD.  Default is 0.\n");
  95.     printf("Bit 1    24/12.  A 1 indicates hours in 24-hour mode and a 0 indicates\n");
  96.     printf("         the 12-hour mode.  Default is 1.\n");
  97.     printf("Bit 0    Daylight Savings Enabled.  A 1 enables daylight savings and a\n");
  98.     printf("         0 disables it.  Default is 0.\n");
  99.     printf("\n");
  100.     printf("STATUS REGISTER C (Hex C)\n");
  101.     printf("Bit 7-4  IRQF, PF, AF, UF - These flag bits are read only and are affected\n");
  102.     printf("         when the 'AIE', 'PIE', and 'UIE' interrupts are enabled in\n");
  103.     printf("         register B.\n");
  104.     printf("Bit 3-0  Reserved\n");
  105.     printf("\n");
  106.     printf("STATUS REGISTER D (Hex D)\n");
  107.     printf("Bit 7    Valid RAM Bit - Indicates the condition of the contents of the\n");
  108.     printf("         CMOS RAM through the power sense pin.  A low state of the power\n");
  109.     printf("         sense pin indicates that the real-time clock has lost its power\n");
  110.     printf("         (battery dead).  A 1 on the VRB indicates ok and a 0 indicates\n");
  111.     printf("         that the real-time clock has lost power.\n");
  112.     printf("Bit 6-0  Reserved\n");
  113.     printf("\n");
  114.     printf("DIAGNOSTIC STATUS BYTE (Hex E)\n");
  115.     printf("Bit 7    Real-Time clock lost power if a 1.\n");
  116.     printf("Bit 6    Configuration Record - Checksum ok if a 0.\n");
  117.     printf("Bit 5    Incorrect Configuration Information if a 1.\n");
  118.     printf("Bit 4    Memory Size Miscompare if a 1.\n");
  119.     printf("Bit 3    Fixed Disk Adapter/Drive C Initialization Status, 1 if failed.\n");
  120.     printf("Bit 2    Time Status Indicator - (POST Validity check), 1 if invalid.\n");
  121.     printf("Bit 1-0  Reserved\n");
  122.     printf("\n");
  123.     printf("SHUTDOWN STATUS BYTE (Hex F)\n");
  124.     printf("Defined by the power on diagnostics.  See BIOS listing.\n");
  125.     printf("\n");
  126.     printf("DISKETTE DRIVE TYPE BYTE (Hex 10)\n");
  127.     printf("Bit 7-4  Type of first diskette drive installed:\n");
  128.     printf("         0000 - No drive present\n");
  129.     printf("         0001 - Double Sided (48 TPI)\n");
  130.     printf("         0010 - High Capacity (96 TPI)\n");
  131.     printf("Bit 3-0  Type of second diskette drive installed.\n");
  132.     printf("\n");
  133.     printf("FIXED DISK TYPE BYTE (Hex 12)\n");
  134.     printf("Bit 7-4  Defines the type of first fixed disk drive (drive C:):\n");
  135.     printf("         0000 - No fixed disk drive is present\n");
  136.     printf("         0001 - 1111 defines type 1 through type 15\n");
  137.     printf("Bit 3-0  Defines the type of second fixed disk drive (drive D:)\n");
  138.     printf("\n");
  139.     printf("EQUIPMENT BYTE (Hex 14)\n");
  140.     printf("Bit 7-6  Number of diskette drives installed: 00 - 1 drive; 01 - 2 drives\n");
  141.     printf("Bit 5-4  Primary display: 00-Reserved; 01-CGA 40; 10-CGA 80; 11-Mono\n");
  142.     printf("Bit 3-2  Not used\n");
  143.     printf("Bit 1    Math Coprocessor present if 1\n");
  144.     printf("Bit 0    Diskette drives are installed if 1\n");
  145.     printf("\n");
  146.     printf("LOW AND HIGH BASE MEMORY BYTES (Hex 15 and 16)\n");
  147.     printf("Bit 7-0  Hex 15 - Low byte\n");
  148.     printf("Bit 7-0  Hex 16 - High byte\n");
  149.     printf("         Valid Sizes:\n");
  150.     printf("         0100H  256Kb system-board RAM\n");
  151.     printf("         0200H  512Kb system-board RAM\n");
  152.     printf("         0280H  640Kb system-board RAM\n");
  153.     printf("\n");
  154.     printf("LOW AND HIGH MEMORY EXPANSION BYTES (Hex 17 and 18)\n");
  155.     printf("Bit 7-0  Hex 17 - Low byte\n");
  156.     printf("Bit 7-0  Hex 18 - High byte\n");
  157.     printf("         Valid Sizes:\n");
  158.     printf("         0200H  512Kb I/O adapter\n");
  159.     printf("         0400H  1024Kb I/O adapter\n");
  160.     printf("         0600H  1536Kb I/O adapter\n");
  161.     printf("           to\n");
  162.     printf("         3C00H  15360Kb I/O adapter (15Mb maximum)\n");
  163.     printf("\n");
  164.     printf("CHECKSUM (Hex 2E and 2F)\n");
  165.     printf("Address hex 2E   High Byte\n");
  166.     printf("Address hex 2F   Low Byte\n");
  167.     printf("         Note: Checksum is on addresses hex 10-20.\n");
  168.     printf("\n");
  169.     printf("LOW AND HIGH EXPANSION MEMORY BYTES (Hex 30 and 31)\n");
  170.     printf("Same meaning as Hex 17 and 18 but value found during POST.\n");
  171.     printf("\n");
  172.     printf("DATE CENTURY BYTE (Hex 32)\n");
  173.     printf("Bit 7-0  BCD value for the century.\n");
  174.     printf("\n");
  175.     printf("INFORMATION FLAG (Hex 33)\n");
  176.     printf("Bit 7    Set if 128KB memory option is installed.\n");
  177.     printf("Bit 6    Used by the Setup utility to put out a first user message after\n");
  178.     printf("         initial setup.\n");
  179.     printf("Bit 5-0  Reserved\n");
  180.     printf("\n");
  181.     printf("I/O OPERATIONS\n");
  182.     printf("Writing to CMOS RAM involves two steps:\n");
  183.     printf("   1. OUT to port hex 70 with a CMOS address that will be written to.\n");
  184.     printf("   2. OUT to port hex 71 with the data to be written.\n");
  185.     printf("\n");
  186.     printf("Reading CMOS RAM involves two steps:\n");
  187.     printf("   1. OUT to port hex 70 with the CMOS address that is to be read from.\n");
  188.     printf("   2. IN from port hex 71, and the data read is returned in AL.\n");
  189. }
  190.  
  191.